<?php

namespace App\Http\Controllers\admin\admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use App\Models\Admin;

class AdminController extends Controller
{
    //
    public function index()
    {
        $list=session('adminlist');
        $id=$list['id'];
        $admin=new Admin();
        $list=$admin->where('id',$id)->first();
        return view('admin.adminself.adminEdit',['list'=>$list]);
    }

    //修改个人信息
    public function xiugai(Request $request)
    {
//        dd($request);
        $admin = new Admin();
        $data = $request->except('_token','_method','pwd');
        $id=$data['id'];
        unset($data['id']);
        $data['password']=md5($data['password']);
        $bool = $admin->where('id',$id)->update($data);
        if($bool){
            $list=$admin->where('id',$id)->first();
            echo "<script>alert('修改成功！');</script>";
            return view('admin.adminself.adminEdit',['list'=>$list]);
        }else{
            return null;
        }

    }
    //显示头像
    public function showhead()
    {
        $list=session('adminlist');
        $id=$list['id'];
        $admin=new Admin();
        $list=$admin->where('id',$id)->first();
        $img=$list->logo;
        return view('admin.adminself.showhead',['img'=>$img]);

    }

}
